package es.cazadoresmadridejos.objs.web;

import javax.servlet.http.HttpServletRequest;

import org.displaytag.properties.SortOrderEnum;

import es.cazadoresmadridejos.objs.criteria.PartnerCriteria;

public class Page {

	public Page(HttpServletRequest request,PartnerCriteria partnerCriteria){
		this(request);
		this.container = partnerCriteria;
		if(request.getParameter("6578706f7274") != null){
			this.setLimit(Integer.MAX_VALUE);
			this.setPage(1);
		}
	}
	public Page(HttpServletRequest request){
		String dir = request.getParameter("dir");
		if(dir != null){
			if(dir.equals("desc")){
				this.sortOrder = SortOrderEnum.DESCENDING;
			}
		}
		String limit = request.getParameter("limit");
		if(limit != null){
			this.limit = Integer.valueOf(limit);
		}
		String page = request.getParameter("page");
		if(page != null){
			this.page = Integer.valueOf(page);
		}
		String sort = request.getParameter("sort");
		if(sort != null){
			this.sort= sort;
		}
	}

	private Integer limit = 10;
	private String sort = "id";
	private Integer page = 1;
	private SortOrderEnum sortOrder = SortOrderEnum.ASCENDING;
	private Object container;


	public Integer getLimit() {
		return limit;
	}
	public void setLimit(Integer limit) {
		this.limit = limit;
	}
	public String getSort() {
		return sort;
	}
	public void setSort(String sort) {
		this.sort = sort;
	}
	public Integer getPage() {
		return page;
	}
	public void setPage(Integer page) {
		this.page = page;
	}
	public SortOrderEnum getSortOrder() {
		return sortOrder;
	}
	public void setSortOrder(SortOrderEnum sortOrder) {
		this.sortOrder = sortOrder;
	}
	public Object getContainer() {
		return container;
	}
	public void setContainer(Object container) {
		this.container = container;
	}
}
